<div id="content">
	<div class="content-bg">
		<!-- start reports block -->
		<div class="big-block">
			<?php
			// Filter::report_stats - The block that contains reports list statistics
			Event::run('ushahidi_filter.report_stats', $report_stats);
			echo $report_stats;
			?>
	
			<!--div class="r_cat_tooltip"> <a href="#" class="r-3">2a. Structures a risque | Structures at risk</a> </div-->
			<div class="reports-box" style="margin-top:0px;float:left;width:100%;">
				<?php
				foreach ($incidents as $incident)
				{
					$incident_id = $incident->id;
					$incident_title = $incident->incident_title;
					$incident_description = $incident->incident_description;
					//$incident_category = $incident->incident_category;
					// Trim to 150 characters without cutting words
					// XXX: Perhaps delcare 150 as constant

					$incident_description = text::limit_chars(strip_tags($incident_description), 150, "...", true);
					$incident_date = date('H:i M d, Y', strtotime($incident->incident_date));
					//$incident_time = date('H:i', strtotime($incident->incident_date));
					$location_id = $incident->location_id;
					$location_name = $incident->location->location_name;
					$incident_verified = $incident->incident_verified;
					$incident_ticket = $incident->incident_ticket;

					if ($incident_verified)
					{
						$incident_verified = '<span class="r_verified">'.Kohana::lang('ui_main.verified').'</span>';
					}
					else
					{
						$incident_verified = '<span class="r_unverified">'.Kohana::lang('ui_main.unverified').'</span>';
					}
					
					if ($incident_ticket != NULL)
					{
						$incident_ticket = '<span class="r_ticket">'.$incident_ticket.'</span>';
					}
					
					//$comment_count = $incident->comment->count();
					$incident_thumb = url::base()."media/img/report-thumb-default.jpg";
					
					foreach ($incident->category as $image)
					{
						switch ($image->id)
						{
							case 1:
							case 6:
							case 7:
							case 8:
							case 9:
							case 10:
							case 21:
								$incident_thumb = url::base()."themes/default/images/icongris/seguridad.png";
								break;
							case 2:
							case 11:
							case 12:
							case 14:
							case 15:
							case 26:
							case 27:
								$incident_thumb = url::base()."themes/default/images/icongris/vialidad.png";
								break;
							case 3:
								$incident_thumb = url::base()."themes/default/images/icongris/emergencias.png";
								break;
							case 5:
							case 17:
							case 18:
							case 25:
								$incident_thumb = url::base()."themes/default/images/icongris/comunidad.png";
								break;
							case 22:
							case 16:
							case 23:
							case 24:
								$incident_thumb = url::base()."themes/default/images/icongris/servicios.png";
								break;
						}
					}
							
					$media = $incident->media;
					if ($media->count())
					{
						foreach ($media as $photo)
						{
							if ($photo->media_thumb)
							{ // Get the first thumb
								$prefix = url::base().Kohana::config('upload.relative_directory');
								$incident_thumb = $prefix."/".$photo->media_thumb;
								break;
							}
						}
					}
					?>
					<div class="rb_report">

						<div class="r_media">
							<p class="r_photo"> <a href="<?php echo url::site(); ?>reports/view/<?php echo $incident_id; ?>" style="border:0px;">
								<img src="<?php echo $incident_thumb; ?>" width="80" height="60" style="border:0px;"/> </a>
							</p>

							<!-- Only show this if the report has a video -->
							<p class="r_video" style="display:none;"><a href="#">Video</a></p>
							
							<!-- Category Selector -->
						  <div class="r_categories">
								<h4><?php echo Kohana::lang('ui_main.categories'); ?></h4>
								<?php
								foreach ($incident->category AS $category)
								{
								
									//don't show hidden categories
									if($category->category_visible == 0)
									{
										continue;
									}
									
									if ($category->category_image_thumb)
									{
										?>
										<a class="r_category" href="<?php echo url::site(); ?>reports/?c=<?php echo $category->id; ?>"><span class="r_cat-box"><img src="<?php echo url::base().Kohana::config('upload.relative_directory')."/".$category->category_image_thumb; ?>" height="16" width="16" /></span> <span class="r_cat-desc"><?php echo $localized_categories[(string)$category->category_title];?></span></a>
										<?php
									}
									else
									{
										?>
										<a class="r_category" href="<?php echo url::site(); ?>reports/?c=<?php echo $category->id; ?>"><span class="r_cat-box" style="background-color:#<?php echo $category->category_color;?>;"></span> <span class="r_cat-desc"><?php echo $localized_categories[(string)$category->category_title];?></span></a>
										<?php
									}
								}
								?>
						  </div>
						</div>

						<div class="r_details">
							<h3>
								<a class="r_title" href="<?php echo url::site(); ?>reports/view/<?php echo $incident_id; ?>">
									<?php echo $incident_title; ?>
								</a> 
								<!--a href="<?php echo url::site(); ?>reports/view/<?php echo $incident_id; ?>#discussion" class="r_comments">
									<?php //echo $comment_count; ?>
								</a--> 
								<?php echo $incident_verified; ?>
								<?php echo $incident_ticket; ?>
							</h3>
							<p class="r_date r-3 bottom-cap"><?php echo $incident_date; ?></p>
							<div class="r_description"> <?php echo $incident_description; ?> </div>
							<p class="r_location">&nbsp;&nbsp;&nbsp;<a href="<?php echo url::site(); ?>reports/?l=<?php echo $location_id; ?>"><?php echo $location_name; ?></a></p>
						</div>
					</div>
				<?php 
				} 
				?>
			</div>
			<?php echo $pagination; ?>
	  </div>
		<!-- end reports block -->
	</div>
</div>
